package com.sls.web.manager.recharge.service.impl;

import java.util.UUID;

import org.springframework.stereotype.Service;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sls.core.common.CommonUtil;
import com.sls.core.socket.Head;
import com.sls.core.socket.SocketDTO;
import com.sls.web.manager.common.Constants;
import com.sls.web.manager.page.Pagination;
import com.sls.web.manager.pojo.UserInfoVO;
import com.sls.web.manager.recharge.pojo.SupplierAccountLog;
import com.sls.web.manager.recharge.querybean.SupplierAccountLogQuery;
import com.sls.web.manager.recharge.service.SupplierAccountLogService;
import com.sls.web.manager.socket.SuperService;

@Service("supplierAccountLogService")
public class SupplierAccountLogServiceImpl extends SuperService implements
		SupplierAccountLogService {
	@Override
	public Pagination<?> queryLog(SupplierAccountLogQuery rQuery,
			UserInfoVO userinfo) throws Exception {
		Gson gson = CommonUtil.gson();
		Head head = new Head();
		head.setRequestId(UUID.randomUUID().toString());
		head.setServiceCode(Constants.QUERY_SUPPLIER_ACCOUNT_LOG);
		head.setIp(userinfo.getCurrentIp());
		head.setUserId(userinfo.getUserId());
		SocketDTO dto = super.send(head, rQuery);
		String body = dto.getBody();
		Pagination<SupplierAccountLog> log = gson.fromJson(body,
				new TypeToken<Pagination<SupplierAccountLog>>() {
				}.getType());

		return log;
	}
}
